﻿using System;
using System.IO;
using System.Web;
using System.Xml;
using System.Data;
using System.Text;
using System.Web.UI;
using System.Web.UI.WebControls;

using LTJ.Web.UI;
using LTJ.Config;
using LTJ.Common;
using LTJ.Common.XML;

namespace uswinweb.datacontrol
{
    public partial class usersubmenulist : BaseWebControl
    {
        protected string submenuid = SASRequest.GetString("submenuid");
        public override void ShowUserControl()
        {
            string configPath = Utils.GetMapPath(BaseConfigs.GetSitePath.ToLower() + "config/usermenu.config");
            XmlDocumentExtender doc = new XmlDocumentExtender();
            doc.Load(configPath);
            XmlNodeList mainmenus = doc.SelectNodes("/dataset/submain");
            DataTable dt = new DataTable();
            dt.Columns.Add(new DataColumn("id"));
            dt.Columns.Add(new DataColumn("title"));
            dt.Columns.Add(new DataColumn("defaulturl"));
            dt.Columns.Add(new DataColumn("etitle"));
            dt.Columns.Add(new DataColumn("frameid"));
            int i = 0;
            foreach (XmlNode subMenuItem in mainmenus)
            {
                if (subMenuItem["menuparentid"].InnerText == submenuid)
                {
                    DataRow dr = dt.NewRow();
                    dr["id"] = i.ToString();
                    dr["title"] = subMenuItem["menutitle"].InnerText;
                    dr["defaulturl"] = subMenuItem["link"].InnerText;
                    dr["etitle"] = subMenuItem["englishname"].InnerText;
                    dr["frameid"] = subMenuItem["frameid"].InnerText;
                    dt.Rows.Add(dr);
                }
                i++;
            }

            dataDT = dt;
            GetPageList("submenuid=" + submenuid);
        }
    }
}